package com.monolithiot.huawei.vo;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Collections;

/**
 * 2019/1/9 Create by 郭文梁
 * WeightRequestBody
 * 重量数据请求体
 *
 * @author 郭文梁
 * @date 2019/1/9
 */
@Data
public class WeightRequestBody {
    public static final String DEFAULT_LANGUAGE_CODE = "ZH";
    public static final int DEFAULT_BUTTON_TYPE = 20;
    public static final String DEFAULT_UPDATE_SCOPE = "6";
    public static final String DEFAULT_DCS_FLAG = "Y";

    private String dcsFlag;
    private String updateScope;
    private String paramters;
    private Integer buttonType;
    private String languageCode;

    /**
     * 设置请求业务参数
     *
     * @param parameters 业务参数对象
     * @return This
     */
    public WeightRequestBody parameter(@NotNull WeightRequestParameters parameters) {
        if (parameters == null) {
            throw new NullPointerException("Parameters object could not be null.");
        }
        this.paramters = JSON.toJSONString(Collections.singletonList(parameters));
        return this;
    }

    /**
     * 转化为JSON字符串
     *
     * @return JSON字符串
     */
    public String toJSON() {
        return JSON.toJSONString(this);
    }
}
